Why isn't my function returning 0 for an empty array in JavaScript

welcome to shbcf.ru